package Operation;

import BOOK.BookList;

/**
 * Creat with IntelliJ IDEA
 * Description:
 * User:WZW
 * Date:2021-11-27
 * Time:18:57
 */
public class Borrow implements IOperation{
    @Override
    public void work(BookList bookList) {
        System.out.println("借阅图书：");
        System.out.println("请输入你要借的书：>");
        String name = scanner.nextLine();
        int index = bookList.search(name);
        if(index==-1){
            System.out.println("很抱歉，没有你要借的书！");
        }else {
            if(bookList.getIndex(index).isBorrowed()==true){
                System.out.println("很抱歉，这本书已被借出！");
            }else {
                bookList.getIndex(index).setBorrowed(true);
                System.out.println("借阅成功！");
            }
        }
    }
}
